package com.smart.manager.pop.repository;


import cn.hutool.core.lang.Opt;
import com.smart.common.entities.core.Page;
import com.smart.manager.pop.entities.body.RBasicDiamondLog;
import com.smart.manager.pop.entities.models.PopBasicDiamondLogs;
import com.smart.manager.pop.entities.models.query.QPopBasicDiamondLogs;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;


/**
 * 活动管理  钻石兑换
 * @author leo
 * @date 2024/01/03
 */
@Service
@Log4j2
@RequiredArgsConstructor
public class PopBasicDiamondLogRepository {

    public Page<PopBasicDiamondLogs> pageList(RBasicDiamondLog.SearchBody search) {
        QPopBasicDiamondLogs query = new QPopBasicDiamondLogs();
        Opt.ofBlankAble(search.getCode()).ifPresent(x -> query.code.contains(x));
        Opt.ofBlankAble(search.getName()).ifPresent(x -> query.name.eq(x));
        query.createTime.desc().setFirstRow(search.firstRow()).setMaxRows(search.maxRows());
        return new Page<PopBasicDiamondLogs>().load(query.findPagedList());
    }

}






